const app = new BasicTableVue({
    data() {
        return {
            api: slogMonitorLogApi,
            columns: [
                new TableColumn({width: 30, type: 'selection'}),
                new TableColumn({prop: 'commandId', title: '指令ID'}),
                new TableColumn({prop: 'reason', title: '监测原因'}),
                new TableColumn({prop: 'houseName', title: '所在机房'}),
                new TableColumn({prop: 'srcIp', title: '源IP'}),
                new TableColumn({prop: 'srcPort', title: '源端口'}),
                new TableColumn({prop: 'destIp', title: '目的IP'}),
                new TableColumn({prop: 'destPort', title: '目的端口'}),
                new TableColumn({prop: 'protocol', title: '协议类型', formatter: this.protocolFormat}),
                new TableColumn({prop: 'domain', title: '域名'}),
                new TableColumn({prop: 'url', title: '网址'}),
                new TableColumn({prop: 'title', title: '标题'}),
                new TableColumn({prop: 'attachment', title: '附件'}),
                new TableColumn({prop: 'gatherTime', title: '采集时间', formatter: TableColumn.datetimeFormat}),
                new TableColumn({prop: 'operating', title: '操作', customComponent: true, width: 100}),
            ],
            houses: [],
            protocolMap: new Map().set(1, 'TCP').set(2, 'UDP').set(3, '其他'),
        }
    },
    methods: {
        createForm() {
            return new MonitorLog();
        },
        async init() {
            this.houses = await baseHouseInfoApi.selectList();
        },
        async showSnapshot(data) {
            //跳转到快照查看页面
            window.open(`/common/forward?pagePath=snapshot/snapshotTemplate&insType=1&url=${data.url}`);
        },
        protocolFormat(row, column, val, index) {
            return this.protocolMap.get(parseInt(val))
        }
    },
})
